<?php
namespace app\models;
use app\models\Basic;

use Yii;

class DomainBindLog extends Basic
{
    
    public static function tableName()
    {
        return '{{%domain_bind_log}}';
    }

    public function rules()
    {
        return [
            ['app_id', 'required', 'message' => 'app_id不能为空', 'on' => 'add'],
            ['app_id', 'integer', 'message' => 'app_id必须为数字，或数字字符串', 
                        'min'=>0, 'tooSmall' => 'app_id最小存储0', 
                        'max'=>18446744073709551615, 'tooBig' => 'app_id最大存储18446744073709551615'],
            // ['old_pc_domain', 'default', 'value' => ''],
            ['old_pc_domain', 'string', 'message' => 'old_pc_domain必须是字符串',
                                'min' => 2, 'tooShort' => 'old_pc_domain最短2位',
                                'max' => 32, 'tooLong' => 'old_pc_domain最长32位'],
            // ['new_pc_domain', 'default', 'value' => ''],
            ['new_pc_domain', 'string', 'message' => 'new_pc_domain必须是字符串',
                                'min' => 2, 'tooShort' => 'new_pc_domain最短2位',
                                'max' => 32, 'tooLong' => 'new_pc_domain最长32位'],
            // ['old_mobile_domain', 'default', 'value' => ''],
            ['old_mobile_domain', 'string', 'message' => 'old_mobile_domain必须是字符串',
                                'min' => 2, 'tooShort' => 'old_mobile_domain最短2位',
                                'max' => 32, 'tooLong' => 'old_mobile_domain最长32位'],
            // ['new_mobile_domain', 'default', 'value' => ''],
            ['new_mobile_domain', 'string', 'message' => 'new_mobile_domain必须是字符串',
                                'min' => 2, 'tooShort' => 'new_mobile_domain最短2位',
                                'max' => 32, 'tooLong' => 'new_mobile_domain最长32位'],
            // ['old_server', 'default', 'value' => 0],
            ['old_server', 'integer', 'message' => 'old_server必须为数字，或数字字符串', 
                        'min'=>0, 'tooSmall' => 'old_server最小存储0', 
                        'max'=>20, 'tooBig' => 'old_server最大存储20'],
            // ['new_server', 'default', 'value' => 0],
            ['new_server', 'integer', 'message' => 'new_server必须为数字，或数字字符串', 
                        'min'=>0, 'tooSmall' => 'new_server最小存储0', 
                        'max'=>20, 'tooBig' => 'new_server最大存储20'],
            ['add_time', 'default', 'value' => '1000-01-01 00:00:00'],
            ['add_time', 'date', 'format'=>'yyyy-MM-dd HH:mm:ss', 'message' => 'add_time非yyyy-MM-dd HH:mm:ss格式'],
            ['effect_time', 'default', 'value' => '1000-01-01 00:00:00'],
            ['effect_time', 'date', 'format'=>'yyyy-MM-dd HH:mm:ss', 'message' => 'effect_time非yyyy-MM-dd HH:mm:ss格式'],
        ];
    }


    /*添加*/
    public function addLog($data)
    {
        $this->scenario = 'add';
        $data['DomainBindLog']['add_time'] = date('Y-m-d H:i:s', time());
        // P($data);
        if($this->load($data) and $this->validate()){
            if($this->save(false)){
                return true;
            }
        }
        return false;
    }
    
}